﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Moving03.Administrator
{
    public partial class WebForm17 : System.Web.UI.Page
    {
        DataClasses1DataContext context = new DataClasses1DataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            int ma = int.Parse(Request.QueryString["ID"]);
            Session["ma"] = ma;
        }

        protected void btnthem_Click(object sender, EventArgs e)
        {
            float giaNhanh = float.Parse(txtgianhanh.Text);
            float giaThuong = float.Parse(txtgiathuong.Text);
            float trongLuong = float.Parse(txttrongluong.Text);
            ChiTietChiPhiNuocNgoai ct = new ChiTietChiPhiNuocNgoai();
            ct.GiaChuyenNhanh = giaNhanh;
            ct.GiaChuyenThuong = giaThuong;
            ct.TrongLuong = trongLuong;
            ct.Id_ChiPhi = int.Parse(Session["ma"].ToString());
            context.ChiTietChiPhiNuocNgoais.InsertOnSubmit(ct);
            context.SubmitChanges();
            GridView1.DataBind();

        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            RequiredFieldValidator1.Enabled = false;
            RequiredFieldValidator2.Enabled = false;
            RequiredFieldValidator3.Enabled = false;
        }

        protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            
        }
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {

        }
        protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
        {
            e.Command.Parameters["@Id_ChiPhi"].Value = int.Parse(Session["ma"].ToString());
        }

        protected void SqlDataSource1_Updated(object sender, SqlDataSourceStatusEventArgs e)
        {
            RequiredFieldValidator1.Enabled = true;
            RequiredFieldValidator2.Enabled = true;
            RequiredFieldValidator3.Enabled = true;
        }
    }
}